From: Jonas Dreßler Date: Thu, 17 Mar 2022 16:08:33 +0000 (+0100) Subject: Replace "long-press" of click action with ClutterLongPressGesture X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~104^2^2~47 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=57e4258690eff791d8aafb1d0c1bbbda155b4207;p=gnome-shell.git Replace "long-press" of click action with ClutterLongPressGesture Nothing fancy here, just a straightforward replacement of one API with another. Part-of: --- diff --git a/js/ui/backgroundMenu.js b/js/ui/backgroundMenu.js index 4b812b250..c88d1efc1 100644 --- a/js/ui/backgroundMenu.js +++ b/js/ui/backgroundMenu.js @@ -37,20 +37,21 @@ export function addBackgroundMenu(actor, layoutManager) { actor._backgroundMenu.open(BoxPointer.PopupAnimation.FULL); } - let clickAction = new Clutter.ClickAction(); - clickAction.connect('long-press', (action, theActor, state) => { - if (state === Clutter.LongPressState.QUERY) { - return (action.get_button() === 0 || - action.get_button() === 1) && - !actor._backgroundMenu.isOpen; - } - if (state === Clutter.LongPressState.ACTIVATE) { - let [x, y] = action.get_coords(); - openMenu(x, y); - actor._backgroundManager.ignoreRelease(); - } - return true; + const longPressGesture = new Clutter.LongPressGesture({ + required_button: Clutter.BUTTON_PRIMARY, }); + longPressGesture.connect('recognize', () => { + if (actor._backgroundMenu.isOpen) + return; + + const coords = longPressGesture.get_coords(); + const point = new Graphene.Point3D({x: coords.x, y: coords.y}); + const transformedPoint = actor.apply_transform_to_point(point); + openMenu(transformedPoint.x, transformedPoint.y); + }); + actor.add_action(longPressGesture); + + const clickAction = new Clutter.ClickAction(); clickAction.connect('clicked', action => { if (action.get_button() === 3) { let [x, y] = action.get_coords();